<?php


namespace app\api\controller\manystore;

use app\admin\model\manystore\ParentStudent;
use app\common\model\manystore\Message;
use app\common\model\manystore\MonitorMessage;
use app\common\model\manystore\Parents;

class User extends Base
{
    public function studentlist()
    {
        $parent = Parents::get(['user_id' => $this->auth->id]);
        $data = ParentStudent::all(['parent_id' => $parent->id]);
        $list = [];
        foreach ($data as $v) {
            $list[] = \app\common\model\manystore\Student::get($v->student_id,['banji']);
        }
        $this->success('返回成功',$list);
    }

    public function message()
    {
        $msg = $this->request->post('msg');
        $monitor_info_id = $this->request->post('monitor_info_id');

        MonitorMessage::create([
            'msg' => $msg,
            'monitor_info_id' => $monitor_info_id,
            'shop_id' =>$this ->shop_id,
            'user_id' => $this->auth->id
        ]);

        $this->success('成功');
    }
}